﻿using System.Collections.Generic;
using DomainModel;
using Repository.Abstract;

namespace Repository.NHibernate
{
    public class WorkTypeRepository : Repository<WorkType>, IWorkTypeRepository
    {
        public WorkType GetBySubjectAndName(Subject subject, string name)
        {
            using (Session)
            {
                return Session.QueryOver<WorkType>().Where(w => w.Subject == subject && w.Name == name).SingleOrDefault();
            }
        }

        public IEnumerable<WorkType> GetBySubjectAndModuleNo(Subject subject, int moduleNo)
        {
            using (Session)
            {
                return Session.QueryOver<WorkType>().Where(w => w.Subject == subject && w.ModuleNo == moduleNo).List<WorkType>();
            }
        }
    }
}